$(function () {
    var getParams = getArgs();
    var currentHotel = getParams.hotel;
    var vipInfoId = getParams.no;
    var vipUserId = getParams.user;
    var symbols = $('#doc').data('symbols');
    toastr.options = {
        "newestOnTop": false,
        "timeOut": 1500,
        "extendedTimeOut": 0,
        "escapeHtml": true,
        "positionClass": "toast-bottom-center"
    };
    if (currentHotel === undefined || currentHotel === '') {
        toastr.error(lang('toastr.grogshop'));
        return;
    }     
    var docBody = $('#doc-body');
    var explainBox = $('#explain-box');
    var requestCard = function () {
        toggleLoading(true);
        ajaxRequest('/Home/Customer/hasUserVipCardDetial', {
            "hotel": currentHotel,
            "vipInfoId": vipInfoId,
            "vipUserId": vipUserId
        }, 'post', function (data) {
            toggleLoading(false);
            var info = data.data;
            var hotelVipInfo = data.data.hotelVipInfo;
            var cardHTML = '';
            if(info.length !== 0){
                if(info.currentDiscount == 0){
                    explainBox.find('.discounts').html(lang('member.04')+parseInt(info.currentDiscountrule)+lang('member.05'));
                }else{
                    explainBox.find('.discounts').html(lang('member.06')+symbols+parseInt(info.currentDiscountrule)+lang('member.07'));
                }     
                $.each(hotelVipInfo, function (key, value) {
                    if(value.level == 0){
                        cardHTML += lang('member.08')+ parseInt(value.levelrule) + lang('member.09')+lang('member.10')+value.name+'<br/>';
                    }else{
                        cardHTML += lang('member.11')+symbols+ value.levelrule + lang('member.12')+lang('member.10')+value.name+'<br/>';
                    }
                    explainBox.find('.upgrade-way').html(cardHTML);
                });   
                $('#card-list').html(cardHTML);  
                docBody.removeClass('hidden');           
            }else{
                toastr.error(lang('member.13'));
                docBody.addClass('hidden');
            }
        }, function(error){
            toggleLoading(false); 
            toastr.error(typeof error.responseJSON === 'undefined' ? lang('tip.server') : error.responseJSON.info);
        });        
    }
    requestCard();  
});
